<%@page import="co.gov.medellin.ssti.sub.model.dao.exception.DAOException"%>
<%@page import="co.gov.medellin.ssti.sub.paoyer.administration.model.vo.UserVO"%>
<%@page import="java.util.Collection"%>
<%@ page contentType="text/html;charset=utf-8"%>
<%@page
	import="co.gov.medellin.ssti.sub.common.ConnectionFactory,co.gov.medellin.ssti.sub.service.AuditoriaService,java.sql.Connection,java.sql.ResultSet,java.sql.SQLException"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="<%= request.getContextPath() + "/css/bloques.css" %>"
	rel="stylesheet" type="text/css">
<title>Usuario Creador</title>

<script type="text/javascript">
       
       function fAceptar(){
        document.form.submit();
        }
        
        function fbuscar(){
        document.form.submit();
        }
        
        function fDesvincular(){
          opener.document.frmauditoria.codusucreador.value = "" ;
          opener.document.frmauditoria.usucreador.value = "";
          window.close();      
        }
        
        function setValues(Codigo, Nombre)
        {
          opener.document.frmauditoria.codusucreador.value = Codigo ;
          opener.document.frmauditoria.usucreador.value = Nombre;
          window.close();                 
         }
         
    </script>
</head>
<body>

	<P>&nbsp;</P>
	<P align="center"></P>
	<P align="center" class="titulosenblanco">USUARIO CREADOR</P>
	<form name="frmCreateUser" method="post" action="usuarioCreador.jsp">
		<div align="center">
			<table
				style="width: 60%; border: 0; padding: 3px; border-spacing: 2px;">
				<tr>
					<td width="25%" height="8" class="celdatabla"><STRONG>Cedula</STRONG>
					</td>
					<td width="75%" height="8" colspan="2"><input type="text"
						class="form" name="cedula" value="" maxlength="10" size="10" /></td>
				</tr>
				<tr>
					<td width="25%" class="celdatabla"><STRONG>Descripcion</STRONG>
					</td>
					<td width="75%" colspan="2"><input type="text" class="form"
						name="usuario" value="" maxlength="20" size="20" /></td>
				</tr>
				<tr>
					<td width="25%" height="8">&nbsp;</td>
					<td width="75%" height="8" colspan="2"></td>
				</tr>

				<tr>
					<td width="25%" height="8"></td>
					<td width="75%" height="8" colspan="2"></td>
				</tr>
				<tr>
					<td width="25%"></td>
					<td width="17%"><input type="submit" value="Buscar"
						onclick="fbuscar" /></td>
					<td width="58%"><input type="button" value="Desvincular"
						onclick="fDesvincular()" /></td>
				</tr>
			</table>
		</div>
		<P></P>
		<P>
			<% 
    AuditoriaService auditoriaService = new AuditoriaService();
    String primeraVez = null;
    primeraVez = (String)session.getAttribute("primeraVez"); 
    Collection<UserVO> rs = null;
      if(primeraVez != null){
          try{
             rs = auditoriaService.findUsers(request.getParameter("cedula"),request.getParameter("usuario"));   
             }catch(Exception e){
              e.printStackTrace();
            }
        }else{
          session.setAttribute("primeraVez","false"); 
        }
     %>
		</P>
		<DIV align="center">
			<% if(primeraVez != null){
      if(rs != null){
        try{%>
			<div align="center">
				<table class="form"
					style="border-spacing: 3px; padding: 2px; width: 60%;">
					<tr>
						<td width="10%" class="headerTable">CODIGO</td>
						<td width="65%" class="headerTable">NOMBRE</td>
						<td width="65%" class="headerTable">DESCRIPCION</td>
						<td width="15%" class="headerTable">SELECCIONAR</td>
					</tr>
					<% for(UserVO vo : rs){  %>
					<tr>
						<td width="10%" class="form"><%=vo.getCode() %></td>
						<td width="65%" class="form"><%= vo.getName() %></td>
						<td width="65%" class="form"><%= vo.getDescription() %></td>
						<td width="15%" class="form"><input type="radio"
							name="seleccionar"
							onclick='setValues(Codigo="<%= vo.getCode() %>",Nombre="<%= vo.getName() %>")' /></td>
					</tr>
					<%}%>
				</table>
			</div>
			<%}catch(DAOException e){
            e.printStackTrace();
          }
        }else{ %>
			<div align="center" class="celdatabla">No se encontraron registros...</div>
			<%}
          }else{
       session.setAttribute("primeraVez","false"); 
       }   
          %>
		</DIV>
	</form>
	<P align="center">&nbsp;</P>

</body>
</html>
